/*
** my_putnbr_base.c for printf in /home/boulah_m/printf
**
** Made by moustafa boulahia
** Login   <boulah_m@epitech.net>
**
** Started on  Tue Nov 15 08:17:36 2011 moustafa boulahia
** Last update Tue Jan 31 12:33:47 2012 moustafa boulahia
*/

#include "my.h"

int	my_putnbr_base_fd(int nb, char *base,int fd)
{
  int	save;
  int	div;
  int	final;

  div = 1;
  if (nb <0)
    {
      my_putchar_fd('-', fd);
      nb = -nb;
    }
  while ((nb/div) >= my_strlen(base))
    {
      div = div * my_strlen(base);
    }
  while (div >= 1)
    {
      final = (nb / div);
      save = nb % div;
      nb = nb/ div;
      my_putchar_fd(base[final], fd);
      nb = save;
      div = div / my_strlen(base);
    }
  return (0);
}
